home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / honeytrouble.swf / scripts / DefineSprite_34_trace_mc / frame_1 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  2.5 KB  |  96 lines

  1. function getIndexArr(str)
  2. {
  3.    var _loc5_ = new Array();
  4.    var _loc2_ = 0;
  5.    while(_loc2_ < str.length)
  6.    {
  7.       if(str.charAt(_loc2_) == "[")
  8.       {
  9.          var _loc4_ = "";
  10.          var _loc1_ = _loc2_ + 1;
  11.          while(_loc1_ < str.length)
  12.          {
  13.             if(str.charAt(_loc1_) == "]")
  14.             {
  15.                _loc5_.push(_loc4_);
  16.                _loc2_ = _loc1_;
  17.                break;
  18.             }
  19.             _loc4_ += str.charAt(_loc1_);
  20.             _loc1_ = _loc1_ + 1;
  21.          }
  22.       }
  23.       _loc2_ = _loc2_ + 1;
  24.    }
  25.    return _loc5_;
  26. }
  27. function getVal(parent, str, new_val)
  28. {
  29.    var i = 0;
  30.    while(i < str.length)
  31.    {
  32.       if(str.charAt(i) == "[")
  33.       {
  34.          var var1_var = parent != undefined ? parent[str.substr(0,i)] : eval(str.substr(0,i));
  35.          break;
  36.       }
  37.       i++;
  38.    }
  39.    if(i == str.length)
  40.    {
  41.       if(new_val != undefined)
  42.       {
  43.          parent != undefined ? (parent[str] = new_val) : eval(str);
  44.       }
  45.       return parent != undefined ? parent[str] : eval(str);
  46.    }
  47.    var var2_index_arr = getIndexArr(str);
  48.    switch(var2_index_arr.length)
  49.    {
  50.       case 1:
  51.          if(new_val != undefined)
  52.          {
  53.             var1_var[Number(var2_index_arr[0])] = new_val;
  54.          }
  55.          return var1_var[Number(var2_index_arr[0])];
  56.       case 2:
  57.          if(new_val != undefined)
  58.          {
  59.             var1_var[Number(var2_index_arr[0])][Number(var2_index_arr[1])] = new_val;
  60.          }
  61.          return var1_var[Number(var2_index_arr[0])][Number(var2_index_arr[1])];
  62.       case 3:
  63.          if(new_val != undefined)
  64.          {
  65.             var1_var[Number(var2_index_arr[0])][Number(var2_index_arr[1])][Number(var2_index_arr[2])] = new_val;
  66.          }
  67.          return var1_var[Number(var2_index_arr[0])][Number(var2_index_arr[1])][Number(var2_index_arr[2])];
  68.       default:
  69.    }
  70. }
  71. function trace_str(str, new_val)
  72. {
  73.    delete curr_val;
  74.    str = str.split(".");
  75.    var _loc1_ = 0;
  76.    while(_loc1_ < str.length)
  77.    {
  78.       if(_loc1_ == str.length - 1 && new_val != undefined)
  79.       {
  80.          curr_val = getVal(curr_val,str[_loc1_],new_val);
  81.       }
  82.       else
  83.       {
  84.          curr_val = getVal(curr_val,str[_loc1_]);
  85.       }
  86.       _loc1_ = _loc1_ + 1;
  87.    }
  88.    return String(curr_val);
  89. }
  90. function swap_depth()
  91. {
  92.    _parent.trace_mc.swapDepths(_parent.getNextHighestDepth() - 1);
  93. }
  94. roll_bar.useHandCursor = false;
  95. intervalID = setInterval(swap_depth,1000);
  96.